package cn.hxzy.controller;


import cn.hxzy.pojo.SysUser;
import cn.hxzy.pojo.User;
import cn.hxzy.service.SysUserService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author songmengxin
 * @since 2021-08-08
 */
@RestController
@CrossOrigin
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;
    @RequestMapping("/SysUserLogin")
    public JSONObject SysUserLogin(HttpServletRequest request,@RequestParam String username,@RequestParam String password){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("userName",username);
        queryWrapper.eq("passWord",password);
        JSONObject jsonObject=new JSONObject();
        int count = sysUserService.count(queryWrapper);
        if (count>0) {

            jsonObject.put("code",0);
            jsonObject.put("msg","登录成功");

        }else{
            jsonObject.put("code",-1);
            jsonObject.put("msg","登录失败");
        }

        return  jsonObject;
    }
}

